package com.hxzy.controll;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.hxzy.domain.Students;
import com.hxzy.service.StudentService;

@RestController
public class Controll {
	
	@Autowired
	private StudentService studentService;
	
	@RequestMapping("/getStudents.do")
	public String getStudents(){
		List<Students> stu=studentService.getStudents();
		String st="[";
		for (Students s : stu) {
			st+="{\"id\":"+s.getId()+","+"\"name\":\""+s.getName()+"\","+"\"age\":"+s.getAge()+","
					+"\"sex\":\""+s.getSex()+"\","+"\"address\":\""+s.getAddress()+"\"},";
		}
		String sr=st.substring(0, st.length()-1);
		sr+="]";
		System.out.println(sr);
		return sr;
		
	}
}
